#ifndef _ITERATOR_H
#define _ITERATOR_H

#include<iostream>
using namespace std;

struct input_iterator_tag_min{};
struct output_iterator_tag_min{};
struct forward_iterator_tag_min:public input_iterator_tag_min{};
struct bidirectional_iterator_tag_min:public forward_iterator_tag_min{};
struct random_access_iterator_tag_min:public bidirectional_iterator_tag_min{};

//迭代器
template<class T,class Category=input_iterator_tag_min,class Distance=ptrdiff_t,class Pointer=T*,class Reference=T&>
struct miniterator
{
    typedef Category    iterator_category_min;
    typedef T           value_type;
    typedef Distance    difference_type;
    typedef Pointer     pointer;
    typedef Reference   reference;
};

//traits萃取
//泛化
template<class Iter>
struct miniterator_traits
{
    typedef typename Iter::iterator_category_min    iterator_category_min;
    typedef typename Iter::value_type               value_type;
    typedef typename Iter::difference_type          difference_type;
    typedef typename Iter::pointer                  pointer;
    typedef typename Iter::reference                reference;
};

//偏特化
template<class Iter>
struct miniterator_traits<Iter*>
{
    typedef random_access_iterator_tag_min    iterator_category_min;
    typedef Iter                              value_type;
    typedef ptrdiff_t                         difference_type;
    typedef Iter*                             pointer;
    typedef Iter&                             reference;
};

template<class Iter>
struct miniterator_traits<const Iter*>
{
    typedef random_access_iterator_tag_min    iterator_category_min;
    typedef Iter                              value_type;
    typedef ptrdiff_t                         difference_type;
    typedef const Iter*                       pointer;
    typedef const Iter&                       reference;
};

#endif